package org.jwos.platform.ajax;

public class JSONResponse {

	protected Object result;

	protected boolean success = false;

	protected String errorCode;
	
	protected String error;
	
	public JSONResponse() {		
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		if(error!=null && error.startsWith("ERROR:")) {
			String[] errors = error.split(":");
			if(errors.length>=1) {
				this.errorCode = errors[1];
			}
			if(errors.length>=2) {				
				this.error = errors[2];
			}
		} else {
			this.error = error;
		}		
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}

	public boolean getSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}
}
